<!--
 * @Author: lixinke 530822237@qq.com
 * @Date: 2022-06-15 11:21:33
 * @LastEditors: lixinke 530822237@qq.com
 * @LastEditTime: 2022-06-16 19:40:35
 * @FilePath: \doctor_endd:\课堂\第三阶段\项目\mobbledoctor\src\components\huanzhe\YaoWu.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div>
    <!-- 导航 -->
      <van-nav-bar
        title="选择药物"
        left-text="返回"
        right-text="保存"
        left-arrow
        @click-left="Fanhui"
        @click-right="Ywtj()"
        />
        <van-divider style="border-block-end: 1px solid #EBEBEB; margin-top:0px;"/>
    <!-- 复选框 -->
        <van-checkbox-group v-model="result" >
        <van-cell-group>
        <van-cell v-for="(item, index) in list" clickable :key="item" :title="` ${item}`" 
        @click="toggle(index)">
        
        <template #right-icon>
        <van-checkbox :name="item" ref="checkboxes" />
      </template>
    </van-cell>
  </van-cell-group>
</van-checkbox-group>
    
 </div>      
</template>

<script>


export default {
  name: "YaoWu",
  data () {
    return {
       ywuserId:'1',
       ywdrugId:'1',
       ywdocId:'1',

      list: ['无药物治疗', '德巴金缓释片', '丙戊酸钠片', '得理多', '奥卡西平口服液', '苯妥英钠/大仑丁(PHT)'],//复选框
      result: [],//复选框
    }
  },
   methods: {
    //将选中的药物添加到患者与药物的关联表中
    Ywtj() {
      //发送请求
      this.$axios({
        url: "/doctorSymptom/addUserDrug", 
        method: "post",
        params: {
          userId: this.ywuserId,
          drugId: this.ywdrugId,
          docId:this.ywdocId,
        },
      }).then((res) => {
        // sessionStorage.setItem("token", data.list.token);
        //跳到主页面
        this.$router.push("/huanzheall");
      });
    },
    //返回
    Fanhui(){
        this.$router.push('/huanzheall');
    },
   
    toggle(index) {//复选框
      this.$refs.checkboxes[index].toggle();
    },
  },
}
</script>

<style  scoped>
.touxiang{
  display: block;
  margin: 0 auto;
}
.content {
    padding: 16px 16px 16px;
}
</style>